const Sequelize = require('sequelize');
const config = require('./config/database').development;

const sequelize = new Sequelize(config.database, config.username, config.password, {
  host: config.host,
  dialect: config.dialect,
  logging: console.log
});

async function testConnection() {
  try {
    await sequelize.authenticate();
    console.log('数据库连接成功');
    const [results] = await sequelize.query('SHOW DATABASES;');
    console.log('可用数据库:', results);
  } catch (error) {
    console.error('数据库连接失败:', error);
  } finally {
    await sequelize.close();
  }
}

testConnection();